gh-156233: Fixing a couple of typos and a few code snippet errors in Python docs - #156475
Conversation
Documentation build overview
|
|
I just noticed #156233 (comment), can you please fix it here as well. Indeed it's currently a def overly_generic[
SimpleTypeVar,
- TypeVarWithDefault = int,
TypeVarWithBound: int,
TypeVarWithConstraints: (str, bytes),
+ TypeVarWithDefault = int,
*SimpleTypeVarTuple = (int, float),
**SimpleParamSpec = (str, bytearray),
](
a: SimpleTypeVar,
- b: TypeVarWithDefault,
- c: TypeVarWithBound,
- d: Callable[SimpleParamSpec, TypeVarWithConstraints],
+ b: TypeVarWithBound,
+ c: TypeVarWithConstraints,
+ d: Callable[SimpleParamSpec, TypeVarWithDefault],
*e: SimpleTypeVarTuple,
): ... |
|
@StanFromIreland have you tried your proposed fix with mypy ( https://github.com/python/mypy ) or any type checker that would use the type annotations? Note that I did NOT make any updates in this PR to that page or the cpython/Doc/reference/compound_stmts.rst Line 1852 in fe3a26f Furthermore, when taking a look at how mypy is processing the kinds of type annotations in the All this makes me wary to bundle that one example in with a simple typo and syntax error fixup PR as there may be more updates needed to that section. |
|
I think it's fine to fix the SyntaxError in this PR, as I suggested. If we need further changes they can be done in a follow up, and in any case, it's outright broken currently anyway. |
|
OK, let's try to fix the prior author's To fix: how about we use cpython/Doc/reference/compound_stmts.rst Line 1856 in fe3a26f And to avoid we can unpack the TypeVarTuple as cpython/Doc/reference/compound_stmts.rst Line 1855 in fe3a26f unpack it also at cpython/Doc/reference/compound_stmts.rst Line 1862 in fe3a26f With both those changes as well as moving Some related checks we can do in MyPy are: Thanks. If the above definition update I propose is OK, I will update the PR accordingly. |
encukou
left a comment
There was a problem hiding this comment.
Apparently the suggested follow-up is too complex. I'd be fine with leaving it to a follow-up PR, so we can merge this one.
|
Sure, let's merge. |
|
Thanks @willy-b for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @willy-b for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @willy-b for the PR, and @StanFromIreland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-157221 is a backport of this pull request to the 3.14 branch. |
|
GH-157222 is a backport of this pull request to the 3.13 branch. |
|
GH-157223 is a backport of this pull request to the 3.15 branch. |
* main: (158 commits) pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (python#156940) pythongh-156233: Fix typos and code snippet errors in the docs (python#156475) pythongh-156837: Refer to yield expressions in generator function definitions (pythonGH-156863) pythongh-155292: Skip updating unicodedata with mismatched interpreter (pythonGH-157066) pythongh-157170: Document the scope of global curses settings (pythonGH-157207) pythongh-155966: Correct handling of `math.tanpi` poles (python#155980) pythongh-157170: Restore use_env() after test_use_prescr_screen in test_curses (pythonGH-157171) pythongh-156910: fix deadlock in type_set_abstractmethods under free-threading (python#156948) pythongh-155648: Write the empty and placeholder IDLE tests (python#156260) pythongh-153569: centralize formatted-string state and source spans (python#156484) pythongh-157137: Mark the PEP 820 soft deprecations as 3.15, not `next` (python#157138) pythongh-152433: Use regular LoadLibrary in UWP for Windows system libs (pythonGH-156972) pythongh-121617: Fix Py_CLEAR() memcpy in C++: replace NULL with _Py_NULL (python#157188) pythongh-157135: Fix documentation errors in the `math.atan{2}pi` functions (python#157136) pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (python#157067) pythongh-156774: Speed up pdb startup with asyncio guard (python#156775) pythongh-156109: Allow static, non-framework iOS builds (python#156110) pythongh-156780: Emscripten: add missing EM_JS_DEPS (python#156798) pythongh-152936: Make privileged functions available on Android (python#152977) pythongh-123018: Keep the libedit history file header when truncating (pythonGH-157165) ...

Hello Python team!
Just sending a PR to fix a couple of typos and a few code snippet errors in Python docs. No changes outside of a few .rst files used to generate content on docs.python.org are made to the Python project. These changes are not claimed to fix other unreported possible issues in the documentation, but rather just the items currently mentioned in #156233 .
On https://docs.python.org/3.16/howto/logging-cookbook.html (archived as is at https://web.archive.org/web/20260827054643/https://docs.python.org/3.16/howto/logging-cookbook.html )
In the sentence
cpython/Doc/howto/logging-cookbook.rst
Line 3923 in fe3a26f
"speciric" should be "specific".
On https://docs.python.org/3.16/library/logging.config.html (archived as is at https://web.archive.org/web/20260827041728/https://docs.python.org/3.16/library/logging.config.html )
It seems the key "." is missing a ":" before its value to avoid
':' expected after dictionary key (<string>, line 6)'for the above.cpython/Doc/library/logging.config.rst
Line 558 in fe3a26f
On https://docs.python.org/3.16/library/pdb.html#pdbcommand-exceptions (archived as is at https://web.archive.org/web/20260827042203/https://docs.python.org/3.16/library/pdb.html#pdbcommand-exceptions )
nit: In the example
There is an extra space on the beginning of the last line
out(), which prevents the snippet from running exactly as is if copy-pasted.cpython/Doc/library/pdb.rst
Line 837 in fe3a26f
In the latest version of https://docs.python.org/3/howto/mro.html#python-2-3-mro (archived as is at https://web.archive.org/web/20260822145356/https://docs.python.org/3/howto/mro.html#python-2-3-mro )
I am not trying in this PR to fix the
non-default type parameter 'TypeVarWithBound' follows default type parameterfor theoverly_genericexample on https://docs.python.org/3.16/reference/compound_stmts.html yet ( caused bycpython/Doc/reference/compound_stmts.rst
Line 1852 in fe3a26f
Let me know if there are any additional backport PRs or other language repos for the docs I need to open manually to propagate these changes (if the automated backports don't end up running for this PR).
Thanks so much!